package com.ruoyi.movie.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.movie.domain.MovieBasics;
import com.ruoyi.movie.service.IMovieBasicsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 影视基础信息Controller
 *
 * @author ruoyi
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/movie/basics")
public class MovieBasicsController extends BaseController
{
    @Autowired
    private IMovieBasicsService movieBasicsService;

    /**
     * 查询影视基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('movie:basics:list')")
    @GetMapping("/list")
    public TableDataInfo list(MovieBasics movieBasics)
    {
        startPage();
        List<MovieBasics> list = movieBasicsService.selectMovieBasicsList(movieBasics);
        return getDataTable(list);
    }

    /**
     * 导出影视基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('movie:basics:export')")
    @Log(title = "影视基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MovieBasics movieBasics)
    {
        List<MovieBasics> list = movieBasicsService.selectMovieBasicsList(movieBasics);
        ExcelUtil<MovieBasics> util = new ExcelUtil<MovieBasics>(MovieBasics.class);
        util.exportExcel(response, list, "影视基础信息数据");
    }

    /**
     * 获取影视基础信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('movie:basics:query')")
    @GetMapping(value = "/{movieBasicsId}")
    public AjaxResult getInfo(@PathVariable("movieBasicsId") Integer movieBasicsId)
    {
        return success(movieBasicsService.selectMovieBasicsById(movieBasicsId));
    }

    /**
     * 新增影视基础信息
     */
    @PreAuthorize("@ss.hasPermi('movie:basics:add')")
    @Log(title = "影视基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MovieBasics movieBasics)
    {
        return toAjax(movieBasicsService.insertMovieBasics(movieBasics));
    }

    /**
     * 修改影视基础信息
     */
    @PreAuthorize("@ss.hasPermi('movie:basics:edit')")
    @Log(title = "影视基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MovieBasics movieBasics)
    {
        return toAjax(movieBasicsService.updateMovieBasics(movieBasics));
    }

    /**
     * 删除影视基础信息
     */
    @PreAuthorize("@ss.hasPermi('movie:basics:remove')")
    @Log(title = "影视基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{movieBasicsIds}")
    public AjaxResult remove(@PathVariable Integer[] movieBasicsIds)
    {
        return toAjax(movieBasicsService.deleteMovieBasicsByIds(movieBasicsIds));
    }
}